home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / network / if-pre-up.d / dhclient3-apparmor next >
Encoding:
Text File  |  2009-03-31  |  1.2 KB  |  39 lines

  1. #!/bin/sh -e
  2. #
  3. # Ensure the AppArmor profile is loaded before dhclient is started on systems
  4. # that support it. This can happen with auto dhcp interfaces when udev is
  5. # started.
  6. #
  7.  
  8. PROFILE="/etc/apparmor.d/sbin.dhclient3"
  9. FORCED="/etc/apparmor.d/force-complain/sbin.dhclient3"
  10. AAPROFILES="/sys/kernel/security/apparmor/profiles"
  11.  
  12. [ "$IFACE" != "lo" ] || exit 0
  13.  
  14. # Exit if apparmor is not installed
  15. test -x /sbin/apparmor_parser || exit 0
  16.  
  17. # Exit if apparmor is neither available nor enabled
  18. grep -q "1" /sys/module/apparmor/parameters/enabled 2>/dev/null || exit 0
  19.  
  20. # Wait for apparmor to load
  21. while [ ! -e "$AAPROFILES" ]; do
  22.     # If apparmor is not loaded by the time we leave rcS, we go into S from
  23.     # another runlevel, or are in a non-S runlevel, just exit
  24.     runlevel | grep -E -q '( [0-9]|[0-9] S)' && exit 0
  25.     sleep 1
  26. done
  27.  
  28. if [ -s "$PROFILE" ] && [ ! -e "$FORCED" ]; then
  29.     # If the profile exists and not in force-complain mode, wait a bit
  30.     # for it to be loaded by apparmor
  31.     for j in 0 1 2 3 4 5 6 7 8 9 ; do
  32.         grep -q '/sbin/dhclient3 ' "$AAPROFILES" && exit 0
  33.         sleep 1
  34.     done
  35.  
  36.     # If we somehow got here, just try to load the profile ourself
  37.     cat $PROFILE | apparmor_parser -a || true
  38. fi
  39.